package practice06;

public class Teacher extends Person{
    //写一个Teacher类继承Person类，除了name，age属性，也有klass属性。也有一个introduce方法，
    //introduce方法返回一个字符串形如：
    //>My name is Tom. I am 21 years old. I am a Teacher. I teach Class 2.

    private int klass;
    public Teacher(String name, int age, int klass) {
        super(name,age);
        this.klass=klass;
    }

    public Teacher(String name, int age) {
        super(name,age);
        int klass=0;
    }

    public int getKlass() {
        return klass;
    }
    public void setKlass(int klass) {
        this.klass = klass;
    }
    //如果klass为空，就会返回：
    //>My name is Tom. I am 21 years old. I am a Teacher. I teach No Class.
    public String introduce(){
        if (klass==0){
            return super.introduce()+" I am a Teacher. I teach No Class.";

        }else {
            return super.introduce()+" I am a Teacher. I teach Class "+klass+".";
        }

    }



}
